package com.cpp.dao;


import java.util.List;

import com.cpp.bean.Tbl_Account;
import com.cpp.db.DBUtils;
import com.cpp.db.ResultRow;



public class Tbl_Account_DAO {

	public int save(Tbl_Account account) {
		int result = 0;
		try {
			String sql = "insert into tbl_account(uid,token,regtime,logintime) values(?,?,?,?)";
			Object[] params = new Object[]{account.getUid(),account.getToken(),account.getRegtime(),account.getLogintime()};
			result = DBUtils.update(sql, params);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return result;
	}
	
	public int update(Tbl_Account account){
		int result = 0;
		String sql = "update tbl_account set logintime = ?,token = ? where id = ?";
		Object[] params = new Object[]{account.getLogintime(),account.getToken(),account.getId()};
		try {
			result = DBUtils.update(sql, params);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}		
		return result;
	}
	
	public int query(String uid){
		int id = 0;
		String sql = "select id,uid from tbl_account where uid = ?";
		Object[] params = new Object[]{uid};
		try {
			id = DBUtils.queryInt(sql, params);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return id;
	}

	
}